import mysql.connector.pooling

pool_name = "mypool"  # 使用简短的名称
config={
    "host":"rm-bp1k95zumtf884o0spo.mysql.rds.aliyuncs.com",
    "port":3306,
    "user":"user_root",
    "password":"Linyi888121dsda",
    "database":"demo",
    "pool_name": pool_name,
}
try:
    pool=mysql.connector.pooling.MySQLConnectionPool(
        **config,
        pool_size=10
    )
    con=pool.get_connection()
    con.start_transaction()
    cursor=con.cursor()
    sql="INSERT INTO t_emp(empno,ename) VALUES(%s,%s)"
    data=[
        [100,"A部门"],[110,"B部门"]
    ]
    cursor.executemany(sql,data)
    con.commit()
except Exception as e:
    if "con" in dir():
        con.rollback()
    print(e)